package com.java.super_;

/**
 * super - 子类
 */
public class Child extends Parent {
    public String name = "子类成员变量";
    public String child;
    
    public Child() {
        super();
    }
    
    public Child(String parent, String child) {
        super(parent);
        this.child = child;
    }
    
    public void func() {
        String name = "子类局部变量";
        System.out.println(name); // 子类局部变量
        System.out.println(this.name); // 子类成员变量
        System.out.println(super.name); // 父类成员变量
    }
    
    public static void main(String[] args) {
        Child child1 = new Child();
        System.out.println(child1.child); // null
        System.out.println(child1.parent); // null
        
        Child child2 = new Child("parent", "child");
        System.out.println(child2.child); // child
        System.out.println(child2.parent); // parent
        child2.func();
    }
}
